package com.tool.write.medile;

import com.alibaba.excel.EasyExcel;
import com.tool.write.entity.Person;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author niuyicong
 * @date 2024/10/21  11:17:34
 * @description 自定义样式
 */
public class CustomizeStyleWrite {
    public static void main(String[] args) {
        List<Person> data = data();
        String fileName = "个人信息，自定义样式" + System.currentTimeMillis() + ".xlsx";
        EasyExcel.write(fileName, Person.class)
                .sheet("自定义样式")
                .registerWriteHandler(new CustomVerticalCellStyleStrategy())
                .doWrite(data);
    }

    public static List<Person> data(){
        List<Person> data = new ArrayList<>();
        Person person1 = new Person("niu",25,new Date(),"男");
        Person person2 = new Person("niuniu",26,new Date(),"男");
        Person person3 = new Person("niuniuniu",27,new Date(),"男");
        data.add(person1);
        data.add(person2);
        data.add(person3);
        return data;
    }
}
